﻿using System.Web;
using System.Web.SessionState;

using System.Web.Security;

namespace iSun.Web.UI.Controls
{
    /// <summary>
    /// 注销用户信息
    /// 
    /// </summary>
    public class LogOut : BaseHandler, IHttpHandler, IRequiresSessionState 
    {
        public bool IsReusable
        {
            // Return false in case your Managed Handler cannot be reused for another request.
            // Usually this would be false in case you have some state information preserved per request.
            get { return true; }
        }

        /// <summary>
        /// You will need to configure this handler in the web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            FormsAuthentication.SignOut();
            context.Session["User"] = null;
            context.Response.Buffer = true;
            context.Response.Cache.SetNoStore();            //设置Cache-Control: no-store HTTP标头
            context.Response.Cache.SetNoServerCaching();    //停止当前响应的所有源服务器缓存
            context.Response.Redirect("Login.aspx");
        }
        #region
        #endregion
    }
}
